package zwp.example.demo1;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.DecimalFormat;

@SpringBootTest
public class Demo6ReplaceAll {

    @Test
    public void test1(){
        String str = "286974351";
        String replacedStr = str.replaceAll("2", "A")
                .replaceAll("43", "B")
                .replaceAll("6", "C")
                .replaceAll("8", "D");
        System.out.println(replacedStr);
    }

    @Test
    public void test2(){
        String str = "2869743.2152";
        double v = Double.parseDouble(str);
        String format = String.format("%.2f", v);
        System.out.println(format);
    }

    @Test
    public void test3(){
        String str = "0.123";
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        String format = decimalFormat.format(Double.parseDouble(str) * 100);
        System.out.println(format);
    }
}
